﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocialShare.BusinessEntities;
using SocialShare.BusinessLogicLayer;

namespace SocialShare.DAL.Facades
{
     [System.ComponentModel.DataObject(true)]
    public class MemberFacade
    {
        private SocialShare_MembersBLL bll = null;
        private SocialShare_Admin_UsersBLL adminUser = null;
        private SocialShare_MemberProfilesBLL userProfile = null;

        public MemberFacade()
        {
            if (adminUser == null)
            {
                adminUser = new SocialShare_Admin_UsersBLL();
            }
        }

        private SocialShare_MembersBLL MemberInstance
        {
            get
            {
                if (bll == null)
                {
                    return bll = new SocialShare_MembersBLL();
                }
                else
                {
                    return bll;
                }
            }

        }

        private SocialShare_MemberProfilesBLL MemberProfileInstance
        {
            get
            {
                if (userProfile == null)
                {
                    return userProfile = new SocialShare_MemberProfilesBLL();
                }
                else
                {
                    return userProfile;
                }
            }

        }


        public SocialShare_Members GetMemberByMember_Id(int member_Id)
        {
            return this.MemberInstance.GetSocialShare_MembersByMember_Id(member_Id);            
        }

        public List<SocialShare_Members> GetAllMembers()
        {
            return this.MemberInstance.GetAllSocialShare_Members();
        }

        public SocialShare_Admin_Users ValidateAdmin(string userName, string password)
        {
            return adminUser.ValidateAdmin(userName, password);
        }

        public SocialShare_Members ValidateUser(string userName, string password)
        {
            return this.MemberInstance.ValidateMember(userName, password);
        }

        public SocialShare_Admin_Users GetAdmin_UsersByAdmin_User_Id(int admin_User_Id)
        {
            return adminUser.GetSocialShare_Admin_UsersByAdmin_User_Id(admin_User_Id);
        }

        public void UpdateAdmin_Users(SocialShare_Admin_Users user)
        {
            adminUser.UpdateSocialShare_Admin_Users(user);
        }

        public int CreateNewMember(SocialShare_Members newSocialShare_Members)
        {
            return this.MemberInstance.CreateNewSocialShare_Members(newSocialShare_Members);
        }

        public int CreateNewMemberProfile(SocialShare_MemberProfiles profile)
        {
            return this.MemberProfileInstance.CreateNewSocialShare_MemberProfiles(profile);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public SocialShare_MemberProfiles GetUserProfileByID(String userId)
        {
            return this.MemberProfileInstance.GetUserProfileByID(userId);
        }

        public SocialShare_Members GetMemberByUserName(string userName)
        {
            return this.MemberInstance.ValidateMember(userName);
        }

        public SocialShare_Members GetMemberByAuthCode(string authCode)
        {
            return this.MemberInstance.GetMemberByAuthCode(authCode);
        }

        public SocialShare_Members GetMemberByScreenName(string screenName)
        {
            return this.MemberInstance.GetMemberByScreenName(screenName);
        }

        public SocialShare_MemberProfiles GetMemberByBlogName(String blogName, Int32 profileId)
        {
            return this.MemberInstance.GetMemberByBlogName(blogName, profileId);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public void UpdateMemberProfile(SocialShare_MemberProfiles memberProfile)
        {
            this.MemberProfileInstance.UpdateSocialShareMemberProfiles(memberProfile);
        }

        public void UpdateMember(SocialShare_Members members)
        {
            this.MemberInstance.UpdateSocialShare_Members(members);
        }
    }
}
